﻿using UnityEngine;
using System.Collections;

namespace Unity.Game.ElisAdvance.PassiveScript
{
    public class VoidWalkerDieExplosion
    {

        private PassiveObject obj;

        public VoidWalkerDieExplosion(PassiveObject active)
        {
            obj = active;
        }

        public void onInit()
        {

            //Debug.Log("explosion:" + obj.getVar("explosionRate").get_vector(0));
            obj.setState(0);

        }

        public void onSetState(int state)
        {
            if (state == 0)
            {
                //obj.getAniManager().setAni();
            }
        }

        public void onProc() 
        {

            int state = obj.getState();
            if (state == 0)
            {
                if (obj.getObjectTime() > 1.5f)
                {
                    obj.sendDestroy();
                }
            }


            /*
            if (Com.checkObjectTime(obj, "CurrentTime", 1.0f))
            {
                if (ObjectManager.getMonsterCount(1) <= 5)
                {

                    GameObject enemy = obj.getPool().get(0);
                    if (enemy)
                    {
                        SendActiveObjectCreatePacket sp = new SendActiveObjectCreatePacket();
                        sp.startWriteFloat();
                        sp.writeFloat(10);
                        sp.writeFloat(10);
                        sp.writeFloat(0);
                        sp.writeFloat(0);
                        sp.writeFloat(obj.getXPos() + Random.Range(-2.0f, 2.0f));
                        sp.writeFloat(obj.getYPos() + 2.0f);
                        sp.writeFloat(1);
                        sp.createActiveObject(enemy);

                        


                    }
                }
            }
            */
        }

    }
}
